package com.xuxueli.applyModules.utils.testzipswager;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
import java.util.UUID;

/**
 * 服务-入参
 */
@Data
public class ServiceRequestParamDTO implements Serializable {

    private static final long serialVersionUID = 8202344978560065069L;

    @ApiModelProperty(value = "编号")
    private Long id;

    @ApiModelProperty(value = "服务编号")
    private Long serviceId;

    @ApiModelProperty(value = "数据类型编号")
    private Long fieldTypeId;

    @ApiModelProperty(value = "编码")
    private String code;

    @ApiModelProperty(value = "名称")
    private String name;

    @ApiModelProperty(value = "是否必填,1:是,0:否")
    private Integer must;

    @ApiModelProperty(value = "是否脱敏,1:是,0:否")
    private Integer sensitivity;

    @ApiModelProperty(value = "是否参与缓存,1:是,0:否")
    private Integer cached;

    @ApiModelProperty(value = "参数说明")
    private String description;

    @ApiModelProperty(value = "创建时间")
    private LocalDateTime createTime;

    @ApiModelProperty(value = "创建人")
    private String createBy;

    @ApiModelProperty(value = "修改时间")
    private LocalDateTime updateTime;

    @ApiModelProperty(value = "修改人")
    private String updateBy;

    @ApiModelProperty(value = "字典信息")
    private Long[] dictionaryIds;

    @ApiModelProperty(value = "父节点编号")
    private Long pid;

    @ApiModelProperty(value = "子节点信息")
    private List<ServiceRequestParamDTO> children;

    //====== ↓适配器新增字段 ======

    @ApiModelProperty(value = "参数类型")
    private String requestType;

    @ApiModelProperty(value = "数据组织")
    private String dataStructure;

    @ApiModelProperty(value = "加密配置 1:无 2:敏感字段加密 3:子节点整体加密")
    private Integer encryptContent;

    //此实体类的id不会唯一了，因为适配器参数id与服务参数的id分别为两张表
    @ApiModelProperty(value = "无实际作用，前端做树需要提供的唯一标识")
    private String uuid;

    //====== ↑适配器新增字段 ======

    public ServiceRequestParamDTO() {
    }

    public ServiceRequestParamDTO(Long fieldTypeId, String code, String name, Integer must, String description,
                                  String requestType, String dataStructure) {
        this.fieldTypeId = fieldTypeId;
        this.code = code;
        this.name = name;
        this.must = must;
        this.description = description;
        this.requestType = requestType;
        this.dataStructure = dataStructure;
    }

    public void setParam(Long fieldTypeId, String code, String name, Integer must,
        String description,
        String requestType, String dataStructure) {
        this.fieldTypeId = fieldTypeId;
        this.code = code;
        this.name = name;
        this.must = must;
        this.description = description;
        this.requestType = requestType;
        this.dataStructure = dataStructure;
    }

    public void setRequestTypeAndStructure(String requestType, String dataStructure) {
        this.requestType = requestType;
        this.dataStructure = dataStructure;
        this.uuid = UUID.randomUUID().toString();
    }
}
